/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
/**
 *
 * @author ANH
 */
public class Hen {
    int x;
    int y;
    boolean istouched;
    Sprite hen;
    public Hen()
    {
        hen=null;
        x=100;
        y=0;
        istouched=false;
    }
    public void loadGraphics(Image image)
    {
        hen=new Sprite(image,41,45);
        hen.setFrame(0);
    }
    public void Render(Graphics g)
    {
         hen.setPosition(x, y);
         hen.paint(g);
    }
     private final Rectangle getArea() {
        return new Rectangle(x, y,41 , 45);
    }

    public final boolean isPressed(int x, int y) {
        return getArea().isPointInside(x, y);
    }
    public boolean OnSelelected(int x,int y){// dành cho chạm( tạm thời)
        if(isPressed(x,y))
        {
            istouched=true;
            return true;
        }
        return false;
    }
    public void OnReleased()
    {
        istouched=false;
    }
}
